package com.daily.DailyStudy.设计模式.观察者模式;

import java.util.Observable;
import java.util.Observer;

public class Java自带的观察者模式类实现 {

    public static class RealSubject extends Observable{
        public void makeChanged(){
            setChanged();
            notifyObservers();;
        }
    }

    public static class RealObserve implements Observer{

        @Override
        public void update(Observable o, Object arg) {
            System.out.println("调用了");
        }
    }

    public static void main(String[] args) {
        RealSubject subject = new RealSubject();
        RealObserve observe = new RealObserve();
        subject.addObserver(observe);
        subject.makeChanged();
    }


}
